/*一次性给服务器发送多条数据，然后查看服务器的处理结果
每一条请求都应该得到正常处理*/

#include "../include/server.hpp"
#include <unistd.h>
#include <cassert>
#include <cstdlib>
#include <cstring>

int main()
{
    Muduo::Socket cli_sock;
    cli_sock.CreateClientSocket(8888, "127.0.0.1");
    std::string req = "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 0\r\n\r\n";
    req += "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 0\r\n\r\n";
    req += "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 0\r\n\r\n";
    req += "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 0\r\n\r\n";
    while(1) {
        int ret = cli_sock.Send((void*)req.c_str(), req.size());

        if(ret < 0){
            perror("出错了\n");
            break;
        }
        char buf[1024] = {0};
        assert(cli_sock.Recv(buf, 1023));
        LOGDEBUG("[%s]", buf);
        sleep(2);
    }
    cli_sock.Close();
    return 0;
}